{extends file="../global.html"}
{block name=body}



 

      
          <div class="content" >
            <!-- 右侧内容框架，更改从这里开始 -->
            <form class="layui-form xbs" action="" >
                <div class="layui-form-pane" style="text-align: center;">
                  <div class="layui-form-item" style="display: inline-block;">
                    <!-- <label class="layui-form-label xbs768">日期范围</label>
                    <div class="layui-input-inline xbs768">
                      <input class="layui-input" placeholder="开始日" id="LAY_demorange_s">
                    </div>
                    <div class="layui-input-inline xbs768">
                      <input class="layui-input" placeholder="截止日" id="LAY_demorange_e">
                    </div> -->
                    <div class="layui-input-inline">
                      <input type="text" name="problem_name"  placeholder="请输入问题" value="{$problem_name}" autocomplete="off" class="layui-input">
                    </div>
                    <div class="layui-input-inline" style="width:80px">
                        <button class="layui-btn"  lay-submit="" lay-filter="sreach"><i class="layui-icon">&#xe615;</i></button>
                    </div>
                  </div>
                </div> 
            </form>
            <xblock><button class="layui-btn" onclick="window.location.href='add'"><i class="layui-icon">&#xe608;</i>添加</button></xblock>
            <table class="layui-table">
                <thead>
                    <tr>
                     <th style="width:5%">
                          ID
                        </th>
                        <th>
                          问题
                        </th>
                        <th>
                          答案
                        </th>
                        <th>
                          是否显示在首页
                        </th>
                        <th>
                          操作
                        </th>
                    </tr>
                </thead>
                <tbody>
                {foreach $res as $k=>$v}

                    <tr class="tr_{$v.problem_id}">
                        
                        <td class="td"> {$v.problem_id}</td>
                        <td class="td" id="problem_name"> {$v.problem_name}</td>
                        
                       
                        <td class="td" id="problem_url">{$v.problem_answer}</td>
                          <td class="td" id="problem_url">{if $v.problem_state ==1 }否{else}是{/if}</td>
                        <td class="td-status">
                                
                              <a title="编辑" href="{url('/run/problem/update/id/'|cat:$v.problem_id)}"
                            class="ml-5" style="text-decoration:none">
                                <i class="layui-icon">&#xe642;</i>
                              </a>
                              <a title="删除" href="javascript:del({$v.problem_id})"  
                                          style="text-decoration:none">
                               
                                    <i class="layui-icon">&#xe640;</i>
                                </a>
                        
                        </td>
                    </tr>
                   {/foreach}
                </tbody>

            </table>
            <!-- 右侧内容框架，更改从这里结束 -->
                <div align="center">
                    {$res->render()}
            </div>
          </div>
          <script type="text/javascript">

 
   
          function del(id){
           if(confirm('确定要删除？')==true){

      // console.log($(this).parent("td").html());

      // Ajax
     $.ajax({
              type:"post",
              data:{ id:id,},
              url:"{url('run/Problem/ajaxDel')}",
                        success:function(msg){
                            // alert(msg);
                            if(msg==true){
                                alert('删除成功');
                                 $('.tr_{$v.problem_id}').remove();
                            }
                           
                         },
                         error:function(){
                                
                        }

                     })

                    }
                     }
                 

   

          </script>
        
{/block}
